package com.ljx.thread.thread03;

/**
 * @author LJX
 * @Description: TODO
 * @Date: 2022/11/1 9:46
 * @Version 1.0
 */
public class TestJoin {
	public static void main(String[] args) {
		JoinThread joinThread=new JoinThread();
		System.out.println("main  ---> begin");
		/**
		 * 当前线程受阻，当前线程是main,就是main线程受阻
		 *joinThread 线程执行直到结束，当前线程才继续执行
 		 */
		joinThread.start();
		try {
			joinThread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}


		System.out.println("main --->over");;
	}
}

class JoinThread extends Thread{
	 boolean run=true;
	@Override
	public void run() {
		if(run){
			for (int i = 0; i < 20; i++) {
				System.out.println(Thread.currentThread().getName()+"~~~~~~~~~~~~~~~"+i);
			}
		}

	}
}